Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fuzzing PKCS7 encrypted inputs #2027

Merged
merged 2 commits into from
Dec 16, 2024
Merged

Fuzzing PKCS7 encrypted inputs #2027

merged 2 commits into from
Dec 16, 2024

Conversation

justsmth
Copy link
Contributor

@justsmth justsmth commented Dec 3, 2024

Issues:

Addresses: CryptoAlg-2786

Description of changes:

Add fuzz testing around processing of PKCS7 encrypted inputs.

Call-outs:

I created an initial fuzz corpus by serializing the test cases from PKCS7Test.TestEnvelope into files.

I completed a several iterations of: running the fuzz test for awhile, then minimizing the corpora, then repeat.

Build

CC=clang CXX=clang++ cmake -GNinja -DFUZZ=1 -B ./build
cmake --build ./build

Fuzzing:

cd fuzz
../build/fuzz/pkcs7_decrypt -max_len=4000 -jobs=8 -workers=8 ./pkcs7_decrypt_corpus

Minimize:

mv pkcs7_decrypt_corpus pkcs7_decrypt_corpus_old && mkdir pkcs7_decrypt_corpus  
../build/fuzz/pkcs7_decrypt -max_len=50000 -merge=1 pkcs7_decrypt_corpus pkcs7_decrypt_corpus_old
rm -Rf pkcs7_decrypt_corpus_old

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.

@justsmth justsmth requested a review from a team as a code owner December 3, 2024 13:55
@codecov-commenter
Copy link

codecov-commenter commented Dec 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.77%. Comparing base (637b5d2) to head (3ff5960).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2027      +/-   ##
==========================================
- Coverage   78.79%   78.77%   -0.03%     
==========================================
  Files         598      598              
  Lines      103722   103724       +2     
  Branches    14743    14742       -1     
==========================================
- Hits        81727    81705      -22     
- Misses      21342    21367      +25     
+ Partials      653      652       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@WillChilds-Klein WillChilds-Klein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note to other reviewers -- i had trouble with the "files changed" tab. i found it easier to review fuzz/pkcs7_decrypt.cc in the "commits" tab.

fuzz/pkcs7_decrypt.cc Outdated Show resolved Hide resolved
fuzz/pkcs7_decrypt.cc Outdated Show resolved Hide resolved
fuzz/pkcs7_decrypt.cc Outdated Show resolved Hide resolved
@justsmth justsmth marked this pull request as draft December 11, 2024 17:39
@justsmth justsmth force-pushed the pkcs7-fuzz branch 5 times, most recently from 67cc3f1 to 6e202ba Compare December 13, 2024 15:38
@justsmth justsmth marked this pull request as ready for review December 13, 2024 17:37
fuzz/pkcs7_decrypt.cc Show resolved Hide resolved
crypto/pkcs7/pkcs7.c Show resolved Hide resolved
crypto/pkcs7/pkcs7.c Outdated Show resolved Hide resolved
@justsmth justsmth merged commit b090db7 into aws:main Dec 16, 2024
123 of 126 checks passed
@justsmth justsmth deleted the pkcs7-fuzz branch December 16, 2024 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants